import {
  setToken,
  removeToken,
  setUserInfo,
  getUserInfo
} from "@/utils/common";

export const user = {
  state: getUserInfo(),
  mutations: {
    SET_USER(state, info) {
      let { token } = info;
      setToken(token);
      setUserInfo(info);
      state = info;
    },

    // eslint-disable-next-line no-unused-vars
    CLEAR_USER(state) {
      state = {};
      removeToken();
    }
  }
};
